package com.google.codemirror2gwt.sample.client;

import com.google.codemirror2_gwt.client.CodeMirrorConfig;
import com.google.codemirror2_gwt.client.CodeMirrorWrapper;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextArea;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Codemirror2gwt_sample implements EntryPoint {

	/**
	 * This is the entry point method.
	 */
	@SuppressWarnings("unused")
	public void onModuleLoad() {
		
		//The GWT text area to bind with code mirror 2
		TextArea textArea = new TextArea();

		String JAVA_CODE = "public class HelloWorld {\n\n"+
				"	/**\n"+
				"	 * @param args\n"+
				"	 */\n"+
				"	public static void main(String[] args) {\n"+
				"		System.out.println(\"Hello World!\");\n"+
				"	}\n"+
				"}";
		textArea.setValue(JAVA_CODE);
		
		RootPanel.get("gwt-content").add(textArea);

		//we create a configuration for code mirror
		CodeMirrorConfig config = CodeMirrorConfig.makeBuilder();
		config = config.setMode("text/x-java").setShowLineNumbers(true).setMatchBrackets(true);

		//then we bind code mirror to the text area
		CodeMirrorWrapper wrapper = CodeMirrorWrapper.createEditorFromTextArea(textArea.getElement(), config);
	}
}
